<h3>Danh sách nhà cung cấp</h3>
<hr>

<style>
	.action {
		float: right;
		margin-right: 50px;
	}
	.frm_finter{
		float: left;
		margin-left: 30px;

	}
	
	td a {
		text-decoration: none;	
	}
</style>

<p class = "frm_finter">
	<form action = "<?php echo base_url().'index.php/provider'; ?>" method = "POST">
		<table cellpadding = '7' width = '100%'>
		<tr>
			<td>Danh mục</td>
			<td>Chế độ giá</td>
			<td>Chế độ thời gian</td>
			<td>Cấp</td>
			<td>Tỉnh</td>
			<td>Tên</th>
			<td>Điện thoại</td>
			
		</tr>
		<tr>
			<td>
			<select name = 'category'>
			<option value = '0'>All</option>
				<?php foreach ($category as $item): ?>
					<option value = '<?php echo $item['id'];?>'><?php echo $item['categoryName'];?></option>
				<?php endforeach;?>
			</select>
			</td>
			<td>
			<select name = 'pricePolicy'>
				<option value = '0'>All</option>
				<?php foreach ($pricePolicy as $item): ?>
					<option value = '<?php echo $item['id'];?>'><?php echo $item['value'];?></option>
				<?php endforeach;?>
			</select>
			</td>
			<td>
			<select name = 'timePolicy'>
			<option value = '0'>All</option>
				<?php foreach ($timePolicy as $item): ?>
					<option value = '<?php echo $item['id'];?>'><?php echo $item['value'];?></option>
				<?php endforeach;?>
			</select>
			</td>
			<td>
			<select name = 'level'>
			<option value = '0'>All</option>
				<?php foreach ($level as $item): ?>
					<option value = '<?php echo $item['level'];?>'><?php echo $item['level'];?></option>
				<?php endforeach;?>
			</select>
			</td>
			
			<td>
			<select name = 'province'>
			<option value = '0'>All</option>
				<?php foreach ($province as $item): ?>
					<option value = '<?php echo $item['province'];?>'><?php echo $item['province'];?></option>
				<?php endforeach;?>
			</select>
			</td>
			<td><input type = 'text' name = 'name'></td>
			<td><input type = 'text' name = 'phone'></td>
			<td><input type = 'submit' name = 'search' value = 'Search'></td>
		</tr>
		<tr>
			<td colspan = '8'></td>
			<td width = '10%'>
			<a href="<?php echo base_url()?>index.php/provider/create" style="border: 0px; float: right; margin-right: 20px">
				<img src="<?php echo base_url()?>template/backend/images/btn_add.png"></img>
			</a>
			</td>
			<td width = '10%'>
			<a onclick="$('form').submit();" href="#">
				<img src="<?php echo base_url()?>template/backend/images/btn_delete.png" style="border: 0px; float: right"></img>
				</a>
			</td>
		</tr>
		</table>
	</form>

</p>

<script type="text/javascript">
function doDelete() {
	answer = confirm("Bạn chắc chắn muốn xóa nhà cung cấp này?");
	if(answer) {
		document.getElementById('frm_delete').submit();
	}  
}
</script> 

<form action="<?php echo base_url().'index.php/provider/delete'?>" method="post" enctype="multipart/form-data" id="form">
<table width="100%" cellpadding="7">
	<tr bgcolor="#ad2f33" style="color: #fff; font-weight: bold">
		<td align="center"><input type="checkbox" onclick="$('input[name*=\'selected\']').attr('checked', this.checked);" /></td>
		<td>Nhà cung cấp</td>
		<td>Địa chỉ</td>
		<td>Số điện thoại</td>
		<td align="center">Hành động</td>
	</tr>
	<?php if ($provider) { ?>
    <?php $class = 'odd_row_style'; ?>
	<?php foreach ($provider as $item) { ?>
	<?php $class = ($class == 'even_row_style' ? 'odd_row_style' : 'even_row_style'); ?>
	<tr class="<?php echo $class; ?>">
		<td align="center"><input type="checkbox" name="selected[]" value="<?php echo $item['id']; ?>" /> </td>
    	<td align="center">
    		<a href="<?php echo base_url().'index.php/provider/view/'.$item['id'] ;?>">
    		<img style = "display:block" width = '120' height = '80' src = '<?php echo base_url().$item['logo']?>'>
    		<?php echo $item['name'] ?>
    		</a>
    	</td>
		<td><?php echo $item['address'].'<br>'.$item['district'].', '.$item['province']; ?></td>

        <td><?php echo $item['phone'] ?></td>
        
    	<td align="center">
    		<a href="<?php echo base_url().'index.php/provider/view/'.$item['id'];?>">Xem</a>
    		<a href="<?php echo base_url().'index.php/provider/update/'.$item['id']?>">Sửa</a>
    	</td>
    </tr>
	<?php } ?>
	<?php } ?>
</table>
</form>
